package com.efast.dmom.mes.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.mes.bean.QualityDefectCode;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.entity.base.IModificationFlags;
import com.efast.dmom.mes.service.QualityDefectService;

@Controller
@RequestMapping(value = "/defect")
public class QualityDefectController {
	
	@Autowired
	private QualityDefectService qualityDefectService = null;
	@RequestMapping(value = "/defectAddOrEdit")
	public @ResponseBody ResultBean save(@RequestBody QualityDefectCode qualityDefectCode) {
		ResultBean resultBean = new ResultBean(true,' ');
		// Judge to add
		if (qualityDefectCode.getModificationFlag()== IModificationFlags.NEW) {
					return qualityDefectService.save(qualityDefectCode);
				// Judge to update
		} else if (qualityDefectCode.getModificationFlag() == IModificationFlags.MODIFIED) {
					return qualityDefectService.update(qualityDefectCode);
		}
		return resultBean;
	}
	@RequestMapping(value = "/batchDeleteById")
	public @ResponseBody ResultBean batchDeleteById(@RequestBody List<QualityDefectCode> list) {
		ResultBean batchDeleteById = qualityDefectService.batchDeleteById(list);
		return batchDeleteById;
	}

}
